package com.xyulu.controller.blog;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.xyulu.entity.BlogTimeEntity;
import com.xyulu.service.BlogTimeService;
import com.xyulu.utils.ShiroUtil;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * @Author Xyulu
 * @Date 2021/4/7 0:19
 * @Version 1.0
 */
@Controller
public class TimeLineController {

    @Resource
    private BlogTimeService timeService;

    @GetMapping("/timeLine")
    public String toTimeLine(HttpServletRequest request){
        List<BlogTimeEntity> times = timeService.list(Wrappers.<BlogTimeEntity>lambdaQuery()
                .orderByDesc(BlogTimeEntity::getCreateTime));
        request.setAttribute("times",times);
        request.setAttribute("user", ShiroUtil.getLocalUserName());
        return "blog/time_line";
    }

}
